 //**************************************************************
 // Sphere.java         Author:20172323wyh
 //**************************************************************
 public class Sphere
 {
    private double diameter, surface_area, volume;

    //-------------------------------------------
    // Sets the initial diameter.
    //-------------------------------------------
    public Sphere()
    {
       diameter = 2;
    }

    //-------------------------------------------
    // diameter accessor.
    //-------------------------------------------
    public double getDiameter()
    {
       return diameter;
    }

    //-------------------------------------------
    // diameter mutator
    //-------------------------------------------
    public void setDiameter(double length)
    {
       diameter = length;
    }

    //------------------------------------------------------
    // Calculate the surface area and volume of the Sphere.
    //------------------------------------------------------
    public double SurfaceArea()
    {
       surface_area = Math.pow((diameter * 0.5), 2) * Math.PI * 4;
       return surface_area;
    }

    public double Volume()
    {
       volume = (4/3) * Math.PI * Math.pow((diameter * 0.5), 3);
       return volume;
    }

    //-------------------------------------------------
    // Returns a string representation of the sphere.
    //-------------------------------------------------
    public String toString()
    {
       return diameter + "\t" + surface_area + "\t" + volume + "\t";
    }
 }

